use "C:\Replication files_Authoritarianism, Political Attitudes and Vote Choice\RE and FE data.dta", clear

**# RANDOM EFFECTS

  
  xtreg im_pref_2W ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
  
  xtreg redistSelf01W ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
  
      xtreg eu_intW ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
	 
  xtreg ptvUKIP01W ageW b0.higheduc b0.ethnic  b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
  
      xtreg ptvCon01W ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
  
  xtreg ptvLab01W ageW b0.higheduc b0.ethnic  b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)

**# FIXED EFFECTS 

    xtreg im_pref_2W ageW b1.incomerec auth01W b7.time b1.p_socgradeW, fe
	 
  xtreg redistSelf01W ageW b1.incomerec auth01W b7.time b1.p_socgradeW, fe  

	xtreg eu_intW ageW b1.incomerec auth01W b7.time b1.p_socgradeW, fe 	
	
  xtreg ptvUKIP01W ageW b1.incomerec auth01W b7.time b1.p_socgradeW, fe 
  
  xtreg ptvCon01W ageW b1.incomerec auth01W b7.time b1.p_socgradeW, fe 
	
  xtreg ptvLab01W ageW b1.incomerec auth01W b7.time b1.p_socgradeW, fe 
  
*Robustness check - no covariates: 

     xtreg im_pref_2W auth01W b7.time, fe
     xtreg redistSelf01W auth01W b7.time, fe
	 xtreg eu_intW auth01W b7.time, fe 
	 xtreg ptvLab01W auth01W b7.time, fe 
	 xtreg ptvUKIP01W auth01W b7.time, fe 
	 xtreg ptvCon01W auth01W b7.time, fe 
 	
		
	
**# INTERACTIONS - Political engagement: 
			
		   use "C:\Replication files_Authoritarianism, Political Attitudes and Vote Choice\RE and FE data.dta", clear	
		   
// Random effects 

summ polattW, detail

			xtreg redistSelf01W c.auth01W#c.polattW ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W polattW b7.time b1.gender, re vce(cluster id)
    margins, dydx(auth01W) at(polattW=(0.421 0.685 0.922))
	
			xtreg im_pref_2W c.auth01W#c.polattW ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W polattW b7.time b1.gender, re vce(cluster id)
    margins, dydx(auth01W) at(polattW=(0.421 0.685 0.922))
	
		xtreg eu_intW c.auth01W#c.polattW ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W polattW b7.time b1.gender, re vce(cluster id)
    margins, dydx(auth01W) at(polattW=(0.421 0.685 0.922))
	
	 xtreg ptvUKIP01W c.auth01W#c.polattW auth01W polattW ageW b0.higheduc b0.ethnic  b1.p_socgradeW b1.incomerec b7.time b1.gender, re vce(cluster id)
   margins, dydx(auth01W) at(polattW=(0.421 0.685 0.922))
   
      xtreg ptvCon01W c.auth01W#c.polattW auth01W polattW ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
   margins, dydx(auth01W) at(polattW=(0.421 0.685 0.922))
   
  xtreg ptvLab01W c.auth01W#c.polattW auth01W polattW ageW b0.higheduc b0.ethnic  b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
 margins, dydx(auth01W) at(polattW=(0.421 0.685 0.922))
 
 // Hybrid models 
 
*Decomposing auth for hybrid models: 

bysort id: egen BPauth=mean(auth01W)			 
	bysort id: gen WPauth=auth01W-BPauth
	
	summ WPauth
	
					xtreg redistSelf01W c.WPauth#c.polattW WPauth BPauth ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec polattW b7.time b1.gender, re vce(cluster id)
    margins, dydx(WPauth) at(polattW=(0.421 0.685 0.922))
	
	
				xtreg im_pref_2W c.WPauth#c.polattW WPauth BPauth ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec polattW b7.time b1.gender, re vce(cluster id)
    margins, dydx(WPauth) at(polattW=(0.421 0.685 0.922))
	
					xtreg eu_intW c.WPauth#c.polattW WPauth BPauth ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec polattW b7.time b1.gender, re vce(cluster id)
    margins, dydx(WPauth) at(polattW=(0.421 0.685 0.922))
	
					xtreg ptvUKIP01W c.WPauth#c.polattW WPauth BPauth ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec polattW b7.time b1.gender, re vce(cluster id)
    margins, dydx(WPauth) at(polattW=(0.421 0.685 0.922))
	
				xtreg ptvCon01W c.WPauth#c.polattW WPauth BPauth ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec polattW b7.time b1.gender, re vce(cluster id)
    margins, dydx(WPauth) at(polattW=(0.421 0.685 0.922))
	
				xtreg ptvLab01W c.WPauth#c.polattW WPauth BPauth ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec polattW b7.time b1.gender, re vce(cluster id)
    margins, dydx(WPauth) at(polattW=(0.421 0.685 0.922))
	
	
	
		   
**# INTERACTIONS - Ethnicity: 
				   
// Random effects 

		  xtreg im_pref_2W c.auth01W#i.ethnic ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
		     margins ethnic, dydx(auth01W)
			 					 

		xtreg redistSelf01W c.auth01W#i.ethnic ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
		     margins ethnic, dydx(auth01W)
			 
		xtreg eu_intW c.auth01W#i.ethnic ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
		     margins ethnic, dydx(auth01W)		
			 
			 
		xtreg ptvUKIP01W c.auth01W#i.ethnic ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
		     margins ethnic, dydx(auth01W)	
			 
		xtreg ptvCon01W c.auth01W#i.ethnic ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
		     margins ethnic, dydx(auth01W)	
			 
		xtreg ptvLab01W c.auth01W#i.ethnic ageW b0.higheduc b0.ethnic b1.p_socgradeW b1.incomerec auth01W b7.time b1.gender, re vce(cluster id)
		     margins ethnic, dydx(auth01W)	
			 
// Hybrid model
			 
		  		xtreg ptvLab01W c.WPauth#i.ethnic WPauth BPauth b0.ethnic ageW b0.higheduc b1.p_socgradeW b1.incomerec b7.time b1.gender, re vce(cluster id)
		     margins ethnic, dydx(WPauth)	
			 
			 